var status = 0;
var selected;
var price = 150;

function start() {
 status = -1;
 action(1, 0, 0);
}

function action(mode, type, selection) {
	if (mode == -1) {
		cm.dispose();
	} else {
		if (mode == 0) {
			cm.sendOk("Bassoe Ownz");
   			cm.dispose();
   			return;
  		}
		if (mode == 1)
   			status++;
  		else
   			status--;
  		if (status == 0) {
   			cm.sendNext("Hello #b#h ##k. I am the new #bName Changer#k on the server! \r\n Not just anyone can use my abilities though, you have to have a special item, that u can get at lucy. \r\n \r\n #bRequirments#k \r\n " + price + " #v4001129#.\r\n#e#rIts free for donators#n#k");
  		} else if (status == 1) {
   			cm.sendGetText("This is the #bVERY#k important part. Below, you see a blank space. Type the name you wish to have there. \r\n \r\n Be warned, you cannot use illeagal names (taken names, names with unknown characters, ect).");
  		} else if (status == 2) {
   			selected = cm.getText();
 			if (selected.length() < 3 || selected.length() > 12) {
				cm.sendOk("Your name must be between 3 ~ 12 characters.");
				cm.dispose();
			}
   			cm.sendYesNo("Are you sure you want #b" + selected + "#k as a name, #h #? ");
  		} else if (status == 3) {
   			if (cm.itemQuantity(4001129) >= price) {
    				cm.setName(selected);
   				cm.gainItem(4001129, -price);
   				cm.sendOk("Done! Your name is now #b" + selected + "!#k If for some reason your name didnt change, please log off, and back in, or simply wait till i reload you.");
   			} else {
    				cm.sendOk("What is this...? It seems you dont have  " + price + " #v4001129#. They can be obtained at lucy!");
    				cm.dispose();
   			}
  		} else if (status == 4) {
   			cm.dispose();
   			cm.reloadChar();
  		}
	}
}